home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / driverkit / driverTypes.h < prev    next >
Text File  |  1994-07-26  |  6KB  |  229 lines

  1. /*     Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved. 
  2.  *
  3.  * driverTypes.h - Data types and #defines for driverServer interface.
  4.  *
  5.  * HISTORY
  6.  * 05-June-91    Doug Mitchell at NeXT
  7.  *      Created. 
  8.  */
  9.  
  10. #ifndef    _DRIVERKIT_DRIVERTYPES_
  11. #define _DRIVERKIT_DRIVERTYPES_
  12.  
  13. #import <bsd/sys/types.h>
  14. #import <mach/port.h>
  15. #import <mach/mach_types.h>
  16. #import <architecture/arch_types.h>
  17. #import <driverkit/return.h>
  18. #import <objc/objc.h>
  19.  
  20. #ifndef    NULL
  21. #define    NULL    0
  22. #endif    NULL
  23.     
  24. /*
  25.  * Simple data types.
  26.  */
  27. typedef unsigned int     IOChannelCommand;
  28. typedef unsigned int    IOChannelEnqueueOption;
  29. typedef unsigned int     IOChannelDequeueOption;
  30. typedef unsigned char     IODescriptorCommand;
  31. typedef unsigned int    IODeviceNumber;
  32. typedef unsigned int     IOObjectNumber;
  33.  
  34. /*
  35.  * Machine-independent DMA channel status.
  36.  */
  37. typedef enum {
  38.     IO_None,            // no appropriate status
  39.     IO_Complete,            // DMA channel idle
  40.     IO_Running,            // DMA channel running 
  41.     IO_Underrun,            // under/overrun
  42.     IO_BusError,            // bus error
  43.     IO_BufferError,            // DMA buffer error
  44. } IODMAStatus;
  45.  
  46.  
  47. typedef enum {
  48.     IO_DMARead,            // device to memory
  49.     IO_DMAWrite            // memory to device
  50. } IODMADirection;
  51.  
  52. /*
  53.  * Machine-independent caching specification.
  54.  */
  55. typedef    enum {
  56.     IO_CacheOff,            // cache inhibit
  57.     IO_WriteThrough,
  58.     IO_CopyBack
  59. } IOCache;
  60.  
  61. /*
  62.  * A typoedef which distinguishes direct, indirect, and pseudo devices.
  63.  */
  64. typedef enum {
  65.     IO_DirectDevice,
  66.     IO_IndirectDevice,
  67.     IO_PseudoDevice
  68. } IODeviceStyle;
  69.  
  70. /*
  71.  * Indicates a range of values.  Used for memory regions, port regions, etc.
  72.  */
  73. typedef struct range {
  74.     unsigned int    start;
  75.     unsigned int    size;
  76. } IORange;
  77.  
  78. /*
  79.  * Map between #defined or enum'd constants and text description.
  80.  */
  81. typedef struct {
  82.     int value;
  83.     const char *name;
  84. } IONamedValue;
  85.  
  86. /*
  87.  * Value-to-string conversion arrays in libDriver.
  88.  */
  89. extern const IONamedValue IODMAStatusStrings[];        // for IODMAStatus
  90.  
  91. /*
  92.  * Specify DMA alignment.
  93.  * A value of 0 means no restriction for associated parameter.
  94.  */
  95. typedef struct {
  96.     unsigned    readStart;
  97.     unsigned    writeStart;
  98.     unsigned    readLength;
  99.     unsigned    writeLength;
  100. } IODMAAlignment;
  101.  
  102. /*
  103.  * Machine-independent type for a machine-dependent DMA buffer.
  104.  */
  105. typedef void *IODMABuffer;
  106.  
  107. /*
  108.  * Memory alignment -- specified as a power of two.
  109.  */
  110. typedef unsigned int    IOAlignment;
  111.  
  112. #define IO_NULL_VM_TASK        ((vm_task_t)0)
  113.  
  114. /*
  115.  * Hardcoded IOSlotId for native devices.
  116.  */
  117. #define IO_NATIVE_SLOT_ID    ((IOSlotId)-1)
  118.  
  119. /*
  120.  * Hardcoded IODeviceType for slot devices.
  121.  */
  122. #define IO_SLOT_DEVICE_TYPE    ((IODeviceType)-1)
  123.  
  124. /*
  125.  * IOSlotId and IODeviceType for non-existent device.
  126.  */
  127. #define IO_NULL_SLOT_ID        ((IOSlotId)0)
  128. #define IO_NULL_DEVICE_TYPE    ((IODeviceType)0)
  129. #define IO_NULL_DEVICE_INDEX    ((IODeviceIndex)0)
  130.  
  131. /*
  132.  * Maximum sizes for IOMapSlot() and IOMapBoard().
  133.  */
  134. #define IO_MAX_BOARD_SIZE    (256 * 1024 * 1024)
  135. #define IO_MAX_NRW_SLOT_SIZE    (15 * 1024 * 1024)
  136. #define IO_MAX_SLOT_SIZE    (16 * 1024 * 1024)
  137.  
  138. /*
  139.  * Standard type for an ASCII name (e.g., deviceName, deviceType).
  140.  */
  141. #define IO_STRING_LENGTH    80
  142. typedef char IOString[IO_STRING_LENGTH];
  143.  
  144. /*
  145.  * Parameter name for get/set parameter RPCs.
  146.  */
  147. #define IO_MAX_PARAMETER_NAME_LENGTH    (64)
  148. typedef char IOParameterName[IO_MAX_PARAMETER_NAME_LENGTH];
  149.  
  150. /* 
  151.  * Actual data arrays passed in get/set parameter RPCs.
  152.  */
  153. #define IO_MAX_PARAMETER_ARRAY_LENGTH    (512)
  154. typedef int IOIntParameter[IO_MAX_PARAMETER_ARRAY_LENGTH];
  155. typedef char IOCharParameter[IO_MAX_PARAMETER_ARRAY_LENGTH];
  156.  
  157. /*
  158.  * Pull in machine specific stuff.
  159.  */
  160.  
  161. #import <driverkit/machine/driverTypes.h>
  162.  
  163. /* 
  164.  * Values for IOChannelCommand.
  165.  */
  166. #define IO_CC_ENABLE_INTERRUPTS        0x00000001    // enable interrrupts
  167. #define IO_CC_DISABLE_INTERRUPTS    0x00000002    // disable interrupts
  168. #define IO_CC_CONNECT_FRAME_LOOP    0x00000004    // create DMA frame 
  169.                             //    loop
  170. #define IO_CC_DISCONNECT_FRAME_LOOP    0x00000008    // disconnect DMA frame
  171.                             //    loop
  172.  
  173. /*
  174.  * m68k only. 
  175.  */
  176. #define IO_CC_START_READ        0x00000008    // start DMA Read
  177. #define IO_CC_START_WRITE        0x00000010    // start DMA Write
  178. #define IO_CC_ABORT            0x00000020    // abort current 
  179.                             //   operation
  180. #define IO_CC_ENABLE_DEVICE_INTERRUPTS    0x00000040    // enable ints, device 
  181.                             //   level
  182. #define IO_CC_DISABLE_DEVICE_INTERRUPTS    0x00000080    // disable ints, device
  183.                             //   level
  184.  
  185. /*
  186.  * Used as channelNumber argument for commands which do not refer to a
  187.  * channel.
  188.  */
  189. #define IO_NO_CHANNEL    (-1)
  190.  
  191.  
  192. /*
  193.  * Values for IOChannelEnqueueOption.
  194.  */
  195. #define IO_CEO_END_OF_RECORD        0x00000001    // end of record
  196. #define IO_CEO_DESCRIPTOR_INTERRUPT    0x00000002    // generate descriptor 
  197.                             //    interrupt
  198. #define IO_CEO_ENABLE_INTERRUPTS    0x00000004    // enable interrupt
  199. #define IO_CEO_ENABLE_CHANNEL        0x00000008    // enable channel (m68k
  200.                             //    only)
  201. #define IO_CEO_DESCRIPTOR_COMMAND    0x00000010    // enable descriptor 
  202.                             // command (nrw only)
  203.  
  204. /*
  205.  * Values for IOChannelDequeueOption.
  206.  * IF IO_CDO_ALL is specified and the channel is running, CR_BUSY will be
  207.  * returned and all other options will be ignored.
  208.  */
  209. #define IO_CDO_DONE            0x00000001    // dequeue completed
  210.                             //   descriptors
  211. #define IO_CDO_ALL            0x00000002    // dequeue all 
  212.                             //   descriptors 
  213. #define IO_CDO_ENABLE_INTERRUPTS    0x00000004    // enable interrupt
  214. #define IO_CDO_ENABLE_INTERRUPTS_IF_EMPTY 0x00000008    // enable interrupt if
  215.                             // no more descriptors
  216.                             // can be dequeued
  217.  
  218. #define IO_NULL_DMA_ID    ((unsigned) 0)
  219.  
  220. typedef void *IOAddressMap;
  221. typedef unsigned int IOPhysicalAddress;
  222. typedef unsigned int IOVirtualAddress;
  223.  
  224. typedef void         (*IOInterruptHandler)(void *identity, 
  225.                 void *state, 
  226.                 unsigned int arg);
  227.  
  228. #endif    _DRIVERKIT_DRIVERTYPES_
  229.